﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VTS.Common;
using VTS.BLL;

public partial class admin_Modules_Result_NewItem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Utility.HasLoggedIn())
            Response.Redirect(Constants.LOGIN_PAGE);

        if (!Page.IsPostBack)
            BindDataForControls();
    }

    private void BindDataForControls()
    {
        NamHocBLL bllNamHoc = new NamHocBLL();
        ddlNamHoc.DataSource = bllNamHoc.GetAll();
        ddlNamHoc.DataValueField = "MaNH";
        ddlNamHoc.DataTextField = "NienKhoa";
        ddlNamHoc.DataBind();

        string currentYear = string.Concat(DateTime.Now.Year, " - ", DateTime.Now.Year + 1);
        ListItem item = ddlNamHoc.Items.FindByText(currentYear);
        if (item != null) item.Selected = true;

        LopBLL bllLop = new LopBLL();
        ddlLop.DataSource = bllLop.GetAll();
        ddlLop.DataTextField = "TenLop";
        ddlLop.DataValueField = "MaLop";
        ddlLop.DataBind();
        ddlLop.SelectedIndex = 0;
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        KQHocSinhBLL bllKq = new KQHocSinhBLL();
        bllKq.Add(ddlNamHoc.SelectedValue, ddlHocKy.SelectedValue, ddlLop.SelectedValue,
                txtLoaiKqHS.Text, CKEditor1.Text);
        Response.Redirect(Constants.DEFAULT_PAGE);
    }
}